layui.config({
    base: "/layui/"
}).extend({
    index: 'lib/index'
}).use(['index', 'form', 'jquery', 'upload', 'table'], function () {
    var form = layui.form,
        table = layui.table,
        upload = layui.upload,
        admin = layui.admin;

        form.verify({
            FinalRate: function (value) {

                if (value<0.2||value>0.6) {
                    return '支付宝结算费率设置不合理';
                }
            }

        });

    var apply = false;

    /**
     * 支付宝资料新增提交
     */
    form.on('submit(alipay_mch_form_ok)', function (data) {

        layer.confirm("确认提交支付宝资料吗，切记不要重复点击", {
            btn: ["确认", "取消"]
        }, function (index, layero) {
            $.ajax({
                url: "/alimchinfo/edit",
                data: data.field,
                type: "post",
                success: function (result) {
                    if (result.code == 1) {
                        layer.msg("编辑成功", {
                            offset: '32%'
                            , icon: 1
                            , time: 0
                            , btn: '知道了'
                            , btnAlign: "c"
                            , shade: 0.4
                            , yes: function () {
                                layer.closeAll();
                            }
                        })
                    } else {
                        layer.msg(result.message, {
                            offset: '32%'
                            , icon: 2
                            , time: 3000
                        }, function () {
                            layer.closeAll();
                        })
                    }
                }
            });
        }, function (index) {

        });

        return false;
    });


    $(".face_file").each(function () {

        var userId = $("#userId").val();

        var base_mch_id = $("#base_mch_id").val();

        var file_btn = $(this).find(".face_file_btn");

        var face_file_img = $(this).find(".face_file_img");

        var fade_file_tip = $(this).find(".fade_file_tip");

        var face_file_input = $(this).find(".face_file_input");

        var keyName = face_file_input.attr("keyName");

        var img_value = face_file_input.val();

        if (img_value != null && img_value != "" && img_value != undefined) {
            var img_url = "/baseInfo/getFiel?fielId=" + img_value;
            face_file_img.attr('src', img_url); //图片链接（base64
        }

        var uploadInst = upload.render({
            elem: file_btn
            , url: '/alimchinfo/fileUpload'
            , data: {userId: userId, id: base_mch_id, keyName: keyName}
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    face_file_img.attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                if (res.code == 1) {
                    //如果上传成功
                    face_file_input.val(res.data.id);
                    return layer.msg('上传成功');
                } else {
                    //上传失败
                    face_file_img.attr('src', ""); //图片链接（base64）
                    return layer.msg('上传失败');
                }
            }
            , error: function () {
                //演示失败状态，并实现重传
                fade_file_tip.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                fade_file_tip.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    })
});


$(function() {
    var availableTags = ["文具及办公用品","鞋帽清洗","歌舞厅/夜店","网络电话、传真","其他专业服务","建筑材料承包商","办公及商务家具（批发商）","出版印刷服务","汽车维修、洗车保养、美容装饰","物流、快递","物流货运服务","金融机构-商业银行服务","金融机构-其他服务","金融机构-自动现金服务","演出票务服务","丧仪殡葬服务","其他会员组织","景观美化与园艺服务","电信运营商","计算机维护和修理服务","活动房车销售商","乐队和文艺表演","话费充值与缴费","信息检索服务（信息平台）","门户网站","网络论坛","软件系统商","家具维修、翻新","拖车服务","成人用品/避孕用品/情趣内衣","机票平台","航空系统商","报纸、杂志","运动和娱乐露营","油漆、清漆用品（批发商）","制服与商务正装定制","活动房车场及野营场所","游泳、SPA、洗浴设备","鞋类销售平台（批发商）","航空公司","档案","机票代理人","测试实验服务","自行车及配件","体育用品/器材","书、期刊和报纸（批发商）","美甲","美容/美发服务","站内清算","手表、钟表和首饰维修店","花木栽种用品、苗木和花卉（批发商）","宠物及宠物用品","药物","典当行","文具、办公用品、复印纸和书写纸（批发商）","农业合作与农具","电器承包商","花店","办公电器和小家电维修","机动车供应及零配件（批发商）","化妆品","电器维修","空调、制冷设备维修","杂货店","数码产品及配件","其他医疗保健服务","家政服务","商用计算机及服务器","广告服务","按摩服务","服装出租","肉、禽、蛋及水产品","水果店","美容SPA和美体保健","会员制批量零售店","家用电器","贵金属投资","不动产代理-房地产经纪","外币汇兑","国外代购及免税店","海上船只遇难救助","打字设备、打印复印机、扫描仪","乐器","团购及折扣店","邮票/纪念币","宗教物品","游轮及巡游航线服务","其他自助","行李箱包","工艺美术用品","艺术品和画廊","其他工程承包商","机动车综合经营","雪车","国家邮政","自助零售","平台类综合商城","自助服务","自助娱乐","露营及旅行汽车","自助借还","婚介服务","男性服饰","未列入其他代码的商用器材","金属产品承包商","商业摄影、设计、绘图服务","导购、经纪和拍卖服务","办公、影印及微缩摄影器材（批发商）","会计、审计、财务服务","婚庆服务","电子档案","财务债务咨询","校园团餐","专业摄影器材","复印及绘图服务","钟表店","综合团餐","文字处理/翻译速记","古玩复制品（赝品）","医学及牙科实验室","房车和娱乐车辆出租","汽车出租","卡车及拖车出租","大型仓储式家庭用品卖场","瓷器、玻璃和水晶摆件","混凝土承包商","慈善和社会公益服务","征信和信用报告咨询服务","债务催收机构","烟草/雪茄","不动产管理－物业管理","计算机软件","超市（非平台类）","刻版排版服务","摩托车及配件","礼品、卡片、纪念品","停车服务","少年宫及青少年发展中心","其他学校和教育服务","木材与建材商店","游乐园、马戏团、嘉年华","配饰商店","健身和运动俱乐部","法律咨询和律师事务所","动物园、水族馆","其他娱乐服务","高尔夫球场","护理和照料服务","电玩娱乐场所","医疗器械","建筑、工程和测量服务","茶叶","装修、装潢、园艺","保健品","运输搬运设备、起重装卸设备","飞机及配件、航道设施","轨道交通设备器材","面包糕点","烟花爆竹","油品燃料经销","拖车、篷车及娱乐用车","棋牌室","展览和艺术场馆","大学与学院","旧商品店、二手商品店","女性成衣","助听器","民营医院","康复和身体辅助用品","公立医院","文物古董","付费电视","手机图铃","在线文学类","大型旅游景点","休闲游戏","运动服饰","灭虫及消毒服务","商户拓展","出租船只","彩票","帐篷和遮阳篷商店","乳制品/冷饮","清洁、保养及门卫服务","船舶及配件销售","视频点播","其他在线应用或综合类","儿童保育服务（含学前教育）","房地产开发商","书籍","个人资金借贷","其他专业零售店","公共事业-自来水缴费","公共事业-清洁服务缴费","玻璃、油漆涂料、墙纸","公共事业-电力缴费","公共事业-煤气缴费","玩具、游戏用品","图书馆","正骨医生","旅行社和旅游服务","行业协会和专业社团","国际货运代理和报关行","公共事业（电、气、水）","加油站、服务站","糖果及坚果商店","手机、通讯设备销售","职业技能培训","商业保理公司","函授学校（成人教育）","金属产品和服务（批发商）","商业和文秘学校","内衣/家居服","眼镜店","直销","P2P","借贷消费平台","直销代理","化工产品","电话外呼直销","按摩医生","电话接入直销","眼科医疗服务","订阅订购服务","机场服务","旅游相关服务直销","上门直销（直销员）","目录直销平台","猎头、职业中介","手足病医疗服务","保险直销（代扣）","汽车零配件","网游运营商（含网页游戏）","网游周边服务、交易平台","消费金融公司","小贷公司","融资租赁公司","汽车金融公司","网络游戏点卡、渠道代理","信托公司","金融租赁公司","游戏系统商","融资担保公司","支付机构","度假用别墅服务","电影院及电影票","社区医疗服务机构、诊所等","证券期货基金","管道及供暖设备","住宿服务（旅馆、酒店、汽车旅馆、度假村等）","出租车服务（TAXI）","路桥通行费","其他工业原料和消耗品","母婴用品","宗教组织","设备、工具、家具和电器出租","未列入其他代码的运输服务","商业摄影摄像服务","药品、药品经营者（批发商）","公关和企业管理服务","洗熨服务（自助洗衣服务）","保安和监控服务","洗衣服务","急救服务","室内清洁服务","各类维修相关服务","干洗店","五金器材及用品（批发商）","家用五金工具","音像制品","布料、缝纫用品和其他纺织品（批发商）","焊接维修服务","电气产品和设备","牙科医生","长途公路客运","酒吧、舞厅、夜总会","GCAS紧急服务（仅限Visa使用）","铁路货运","快餐店","咖啡厅、茶馆","音像制品出租","宴会提供商","餐厅、订餐服务","Visa信任服务","家用纺织品","兽医服务","葡萄酒生产商","其他食品零售","家用电子游戏","其他酒类生产商","电汇和汇票服务","摄影服务","汽车、二手车销售","男士用品：剃须刀、烟酒具、瑞士军刀","其他综合零售","鞋类","草坪和花园用品","其他工业耐用品","裁缝、修补、改衣制衣","假发等饰品","桌球/桌游","各类服装及饰物","保龄球","未列入其他代码的建材（批发商）","窗帘、帷幕、室内装潢","家具/家庭摆设","酒类","地板和地毯","壁炉、屏风","各种家庭装饰专营","船舶、海运服务提供商","SNS社交网站","网站设计、推广","清洁抛光服务","高档时装及奢侈品","互联网IDC服务","体育场馆","保险公司","工业设备和制成品","保险代理","珠宝和金银饰品","艺术创作服务","公共交通","汽车协会","铁路客运","皮草皮具","中小学校"];
    $( "#autocomplete" ).autocomplete({
        source: availableTags
    });

});


